package com.llyb.result;

import lombok.Data;

@Data
public class ResultData<T> {

    private String code;
    private String message;
    private T data;

    private long timeStamp;
    private String traceId;

    public ResultData() {
        this.timeStamp = System.currentTimeMillis();
    }

    public static <T> ResultData<T> success(T data){
        ResultData<T> resultData = new ResultData<>();

        resultData.setCode(ReturnCodeEnum.RC200.getCode());
        resultData.setMessage(ReturnCodeEnum.RC200.getMessage());
        resultData.setData(data);

        return resultData;
    }

    public static <T> ResultData<T> fail(String code,String message){
        ResultData<T> resultData = new ResultData<>();

        resultData.setCode(code);
        resultData.setMessage(message);

        return resultData;
    }


}
